import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';

import { AppController } from './app.controller';
import { AppService } from './app.service';
import { CartModule } from './cart/cart.module';
import { ProductModule } from './product/product.module';
import { CategoryModule } from './category/category.module';

import AppDataSource from '../index'
import { ProductController } from './product/product.controller';
import { CategoryController } from './category/category.controller';
import { CartController } from './cart/cart.controller';
import { ProductService } from './product/product.service';
import { CartService } from './cart/cart.service';
import { CategoryService } from './category/category.service';
import { Product } from './entities/product.entity';
import { Cart } from './entities/cart.entity';
import { Category } from './entities/category.entity';
import { ProductOption } from './entities/product-option.entity';
import { ProductOptionsModule } from './product-options/product-options.module';
import { ProductOptionsService } from './product-options/product-options.service';
import { ProductOptionsController } from './product-options/product-options.controller';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mysql',
      host: 'localhost',
      port: 3306,
      username: 'root',
      password: 'lfx7788fanpan',
      database: 'Taro-react-wx-backend',
      entities: [Product, ProductOption, Cart, Category],
      synchronize: false,
      connectorPackage: 'mysql2',
      logging: false,
    }),
    TypeOrmModule.forFeature([Product, Cart, Category, ProductOption]), 
    CartModule, 
    ProductModule, 
    CategoryModule, 
    ProductOptionsModule
  ],
  controllers: [AppController, ProductController, CategoryController, CartController, ProductOptionsController],
  providers: [AppService, ProductService, CartService, CategoryService, ProductOptionsService],
})
export class AppModule {}
